<?php

$container = $app->getContainer();

$container["view"] = function($c) {
    $view = new \Slim\Views\Twig('../src/tpl/' , [
        //'cache' => '../src/tpl-cache'
    ]);
    $basePath = rtrim(str_ireplace('index.php', '', $c['request']->getUri()->getBasePath()) , '/');
    $view->addExtension(new Slim\Views\TwigExtension($c['router'] , $basePath));
    return $view;
};

$container["logger"] = function($c) {
    $settings = $c->get("settings")["logger"];
    $logger = new Monolog\Logger($settings["name"]);
    $logger->pushProcessor(new Monolog\Processor\UidProcessor());
    $logger->pushHandler(new Monolog\Handler\StreamHandler($settings["path"], $settings["level"]));
    return $logger;
};